home *** CD-ROM | disk | FTP | other *** search
/ Mac Magazin/MacEasy 32 / Mac Magazin and MacEasy Magazine CD - Issue 32.iso / Grafik & Text / OzTeX3.0 / TeX-inputs / Plain / cwebmac.tex < prev    next >
Text File  |  1996-03-25  |  10KB  |  233 lines

  1. % standard macros for WEB listings (in addition to PLAIN.TEX)
  2. % $Revision: 1.1 $
  3. \let\amp=\&
  4. \parskip 0pt % no stretch between paragraphs
  5. \parindent 1em % for paragraphs and for the first line of C text
  6.  
  7. \font\eightrm=cmr8 % this will eventually become cmr8
  8. \let\sc=\eightrm \let\mainfont=\tenrm
  9. \font\titlefont=cmr7 scaled\magstep4 % title on the contents page
  10. \font\ttitlefont=cmtt10 scaled\magstep2 % typewriter type in title
  11. \font\tentex=cmtex10 % TeX extended character set (used in strings)
  12.  
  13. \def\\#1{\leavevmode\hbox{\it#1\/\kern.05em}} % italic type for identifiers
  14. \def\|#1{\leavevmode\hbox{$#1$}} % one-letter identifiers look better this way
  15. \def\{\leavevmode\hbox{\bf#1\/}} % boldface type for reserved words
  16. \def\.#1{\leavevmode\hbox{\tentex % typewriter type for strings
  17.   \let\\=\BS % backslash in a string
  18.   \let\'=\RQ % right quote in a string
  19.   \let\`=\LQ % left quote in a string
  20.   \let\{=\LB % left brace in a string
  21.   \let\}=\RB % right brace in a string
  22.   \let\~=\TL % tilde in a string
  23.   \let\ =\SP % space in a string
  24.   \let\_=\UL % underline in a string
  25.   \let\&=\AM % ampersand in a string
  26.   #1}}
  27. \def\nxt#1{\ifx#1\egroup#1\else#1\discretionary{\\}{}{}\expandafter\nxt\fi}
  28. \def\)#1{\leavevmode\bgroup\tentex % breakable typewriter type
  29.   \let\\=\BS % backslash in a string
  30.   \let\'=\RQ % right quote in a string
  31.   \let\`=\LQ % left quote in a string
  32.   \let\{=\LB % left brace in a string
  33.   \let\}=\RB % right brace in a string
  34.   \let\~=\TL % tilde in a string
  35.   \let\ =\SP % space in a string
  36.   \let\_=\UL % underline in a string
  37.   \let\&=\AM % ampersand in a string
  38.   \nxt#1\egroup}
  39. \def\^{\ifmmode\mathchar"222 \else\char`^ \fi} % pointer or hat
  40. % circumflex accents can be obtained from \^^D instead of \^
  41. \def\AT{@} % at sign for control text
  42.  
  43. \chardef\AM=`\& % ampersand character in a string
  44. \chardef\BS=`\\ % backslash in a string
  45. \chardef\LB=`\{ % left brace in a string
  46. \def\LQ{{\tt\char'22}} % left quote in a string
  47. \chardef\RB=`\} % right brace in a string
  48. \def\RQ{{\tt\char'23}} % right quote in a string
  49. \def\SP{{\tt\char`\ }} % (visible) space in a string
  50. \chardef\TL=`\~ % tilde in a string
  51. \chardef\UL=`\_ % underline character in a string
  52.  
  53. \newbox\bak \setbox\bak=\hbox to -1em{} % backspace one em
  54. \newbox\bakk\setbox\bakk=\hbox to -2em{} % backspace two ems
  55.  
  56. \newcount\ind % current indentation in ems
  57. \def\1{\global\advance\ind by1\hangindent\ind em} % indent one more notch
  58. \def\2{\global\advance\ind by-1} % indent one less notch
  59. \def\3#1{\hfil\penalty#10\hfilneg} % optional break within a statement
  60. \def\4{\copy\bak} % backspace one notch
  61. \def\5{\hfil\penalty-1\hfilneg\kern2.5em\copy\bakk\ignorespaces}% optional break
  62. \def\6{\ifmmode\else\par % forced break
  63.   \hangindent\ind em\noindent\kern\ind em\copy\bakk\ignorespaces\fi}
  64. \def\7{\Y\6} % forced break and a little extra space
  65. \def\8{\hskip-\ind em\hskip 2em} % no indentation
  66.  
  67. \let\yskip=\smallskip
  68. \def\?{\mathrel?}
  69. \def\note#1#2.{\Y\noindent{\hangindent2em\baselineskip10pt\eightrm#1 #2.\par}}
  70. \def\lapstar{\rlap{*}}
  71. \def\startsection{\Q\noindent{\let\*=\lapstar\bf\modstar.\quad}}
  72. \def\defin#1{\global\advance\ind by 2 \1\&{#1 }} % begin `define' or `format'
  73. \def\A{\note{See also}} % cross-reference for multiply defined section names
  74. \def\B{\mathopen{\.{@/\ast}}} % begin controlled comment
  75. \def\C#1{\ifmmode\gdef\XX{\null$\null}\else\gdef\XX{}\fi % C comments
  76.   \XX\hfil\penalty-1\hfilneg\quad$/\ast\,$#1$\,\ast/$\XX}
  77. \def\D{\defin{\#define}} % macro definition
  78. \def\F{\defin{format}} % format definition
  79. \let\G=\ge % greater than or equal sign
  80. \let\I=\ne % unequal sign
  81. \def\J{\.{@\&}} % TANGLE's join operation
  82. \let\K== % can be changed to left arrow, if desired
  83. \let\L=\le % less than or equal sign
  84. \outer\def\M#1.{\MN#1.\ifon\vfil\penalty-100\vfilneg % beginning of section
  85.   \vskip12ptminus3pt\startsection\ignorespaces}
  86. \outer\def\N#1.#2.{\MN#1.\vfil\eject % beginning of starred section
  87.   \def\rhead{\uppercase{\ignorespaces#2}} % define running headline
  88.   \message{*\modno} % progress report
  89.   \edef\next{\write\cont{\Z{#2}{\modno}{\the\pageno}}}\next % to contents file
  90.   \ifon\startsection{\bf\ignorespaces#2.\quad}\ignorespaces}
  91. \def\MN#1.{\par % common code for \M, \N
  92.   {\xdef\modstar{#1}\let\*=\empty\xdef\modno{#1}}
  93.   \ifx\modno\modstar \onmaybe \else\ontrue \fi \mark{\modno}}
  94. \def\O#1{% octal, hex or decimal constant
  95.   {\def\?{\kern.2em}%
  96.   \def\${\ell}% long constant
  97.   \def\_{\cdot 10^{\aftergroup}}% power of ten
  98.   \def\~{\hbox{\rm\char'23\kern-.2em\it\aftergroup\?\aftergroup}}% octal
  99.   \def\^{\hbox{\rm\char"7D\tt\aftergroup}}#1}}% double quotes for hex constant
  100. \def\P{\rightskip=0pt plus 100pt minus 10pt % go into C mode
  101.   \sfcode`;=3000
  102.   \pretolerance 10000
  103.   \hyphenpenalty 9999 % so strings can be broken (a discretionary \ is inserted)
  104.   \exhyphenpenalty 10000
  105.   \global\ind=2 \1\ \unskip}
  106. \def\Q{\rightskip=0pt % get out of C mode
  107.   \sfcode`;=1500 \pretolerance 200 \hyphenpenalty 50 \exhyphenpenalty 50 }
  108. \let\R=\lnot % logical not
  109. \let\S=\equiv % equivalence sign
  110. \def\T{\mathclose{\.{@\ast/}}} % terminate controlled comment
  111. \def\U{\note{This code is used in}} % cross-reference for uses of sections
  112. \let\V=\lor % logical or
  113. \let\W=\land % logical and
  114. \def\X#1:#2\X{\ifmmode\gdef\XX{\null$\null}\else\gdef\XX{}\fi % section name
  115.   \XX$\langle\,$#2{\eightrm\kern.5em#1}$\,\rangle$\XX}
  116. \def\Y{\par\yskip}
  117. \let\Z=\let % now you can \send the control sequence \Z
  118. \def\]{\hbox{\.{@\\}}} % sign for forced line break
  119. \def\=#1{\kern2pt\hbox{\vrule\vtop{\vbox{\hrule
  120.         \hbox{\strut\kern2pt\.{#1}\kern2pt}}
  121.       \hrule}\vrule}\kern2pt} % verbatim string
  122. \let\~=\ignorespaces
  123. \let\*=*
  124.  
  125. \def\onmaybe{\let\ifon=\maybe} \let\maybe=\iftrue
  126. \newif\ifon \newif\iftitle \newif\ifpagesaved
  127. \def\lheader{\mainfont\the\pageno\eightrm\qquad\rhead\hfill\title\qquad
  128.   \tensy x\mainfont\topmark} % top line on left-hand pages
  129. \def\rheader{\tensy x\mainfont\topmark\eightrm\qquad\title\hfill\rhead
  130.   \qquad\mainfont\the\pageno} % top line on right-hand pages
  131. \def\page{\box255 }
  132. \def\normaloutput#1#2#3{\shipout\vbox{
  133.   \ifodd\pageno\hoffset=\pageshift\fi
  134.   \vbox to\fullpageheight{
  135.   \iftitle\global\titlefalse
  136.   \else\hbox to\pagewidth{\vbox to10pt{}\ifodd\pageno #3\else#2\fi}\fi
  137.   \vfill#1}} % parameter #1 is the page itself
  138.   \global\advance\pageno by1}
  139.  
  140. \def\rhead{\.{WEB} OUTPUT} % this running head is reset by starred sections
  141. \def\title{} % an optional title can be set by the user
  142. \def\topofcontents{\centerline{\titlefont\title}
  143.   \vfill} % this material will start the table of contents page
  144. \def\botofcontents{\vfill} % this material will end the table of contents page
  145. \def\contentspagenumber{0} % default page number for table of contents
  146. \newdimen\pagewidth \pagewidth=6.5in % the width of each page
  147. \newdimen\pageheight \pageheight=8.7in % the height of each page
  148. \newdimen\fullpageheight \fullpageheight=9in % page height including headlines
  149. \newdimen\pageshift \pageshift=0in % shift righthand pages wrt lefthand ones
  150. \def\magnify#1{\mag=#1\pagewidth=6.5truein\pageheight=8.7truein
  151.   \fullpageheight=9truein\setpage}
  152. \def\setpage{\hsize\pagewidth\vsize\pageheight} % use after changing page size
  153. \def\contentsfile{\jobname.toc} % file that gets table of contents info
  154. \def\readcontents{\input \jobname.toc}
  155.  
  156. \newwrite\cont
  157. \output{\setbox0=\page % the first page is garbage
  158.   \openout\cont=\contentsfile
  159.   \global\output{\normaloutput\page\lheader\rheader}}
  160. \setpage
  161. \vbox to \vsize{} % the first \topmark won't be null
  162.  
  163. \def\ch{\note{The following sections were changed by the change file:}
  164.   \let\*=\relax}
  165. \newbox\sbox % saved box preceding the index
  166. \newbox\lbox % lefthand column in the index
  167. \def\inx{\par\vskip6pt plus 1fil % we are beginning the index
  168.   \write\cont{} % ensure that the contents file isn't empty
  169.   \closeout\cont % the contents information has been fully gathered
  170.   \output{\ifpagesaved\normaloutput{\box\sbox}\lheader\rheader\fi
  171.     \global\setbox\sbox=\page \global\pagesavedtrue}
  172.   \pagesavedfalse \eject % eject the page-so-far and predecessors
  173.   \setbox\sbox\vbox{\unvbox\sbox} % take it out of its box
  174.   \vsize=\pageheight \advance\vsize by -\ht\sbox % the remaining height
  175.   \hsize=.5\pagewidth \advance\hsize by -10pt
  176.     % column width for the index (20pt between cols)
  177.   \parfillskip 0pt plus .6\hsize % try to avoid almost empty lines
  178.   \def\lr{L} % this tells whether the left or right column is next
  179.   \output{\if L\lr\global\setbox\lbox=\page \gdef\lr{R}
  180.     \else\normaloutput{\vbox to\pageheight{\box\sbox\vss
  181.         \hbox to\pagewidth{\box\lbox\hfil\page}}}\lheader\rheader
  182.     \global\vsize\pageheight\gdef\lr{L}\global\pagesavedfalse\fi}
  183.   \message{Index:}
  184.   \parskip 0pt plus .5pt
  185.   \outer\def\:##1, {\par\hangindent2em\noindent##1:\kern1em} % index entry
  186.   \def\[##1]{$\underline{##1}$} % underlined index item
  187.   \rm \rightskip0pt plus 2.5em \tolerance 10000 \let\*=\lapstar
  188.   \hyphenpenalty 10000 \parindent0pt}
  189. \def\fin{\par\vfill\eject % this is done when we are ending the index
  190.   \ifpagesaved\null\vfill\eject\fi % output a null index column
  191.   \if L\lr\else\null\vfill\eject\fi % finish the current page
  192.   \parfillskip 0pt plus 1fil
  193.   \def\rhead{NAMES OF THE SECTIONS}
  194.   \message{Section names:}
  195.   \output{\normaloutput\page\lheader\rheader}
  196.   \setpage
  197.   \def\note##1##2.{\quad{\eightrm##1 ##2.}}
  198.   \def\U{\note{Used in}} % cross-reference for uses of sections
  199.   \def\:{\par\hangindent 2em}\let\*=*}
  200. \def\con{\par\vfill\eject % finish the section names
  201.   \rightskip 0pt \hyphenpenalty 50 \tolerance 200
  202.   \setpage
  203.   \output{\normaloutput\page\lheader\rheader}
  204.   \titletrue % prepare to output the table of contents
  205.   \pageno=\contentspagenumber \def\rhead{TABLE OF CONTENTS}
  206.   \message{Table of contents:}
  207.   \topofcontents
  208.   \line{\hfil Section\hbox to3em{\hss Page}}
  209.   \def\Z##1##2##3{\line{\ignorespaces##1
  210.     \leaders\hbox to .5em{.\hfil}\hfil\ ##2\hbox to3em{\hss##3}}}
  211.   \readcontents\relax % read the contents info
  212.   \botofcontents \end} % print the contents page(s) and terminate
  213. \tracingstats1 % temporary (during development)
  214. \def\FE{\mathrel{/=}}
  215. \def\PP{\mathord{++}}
  216. \def\PE{\mathrel{+=}}
  217. \def\MM{\mathord{--}}
  218. \def\ME{\mathrel{-=}}
  219. \def\MG{\mathrel{\to}}
  220. \def\GG{\mathrel{>\!>}}
  221. \def\LL{\mathrel{<\!<}}
  222. \def\TE{\mathrel{\ast=}}
  223. \def\CE{\mathrel{\%=}}
  224. \def\HE{\mathrel{\uparrow=}}
  225. \def\AE{\mathrel{\&=}}
  226. \def\OE{\mathrel{|=}}
  227. \let\openbraces=\{
  228. \let\closebraces=\}
  229. \def\{{\ifmmode\openbraces\else$\openbraces$\fi}
  230. \def\}{\ifmmode\closebraces\else$\closebraces$\fi}
  231.  
  232.  
  233.